import java.util.Scanner;

public class jishuwenti {
        public static void main(String[] args) {
            Scanner in=new Scanner(System.in);
            int a=in.nextInt();
            int n=in.nextInt();
            String aa=String.valueOf(n) ;
            char b=aa.charAt(0);
            int d=0;
            for (int i = 1; i <=a ; i++) {
                String str=String.valueOf(i);
                char[] c=str.toCharArray();
                for (int j = 0; j <c.length; j++) {
                    if(c[j]==b)d++;
                }
            }
            System.out.println(d);
        }

}
